<button class="btn btn-success btn-xs" data-toggle="modal" data-target="#taskFollowUp{{ $id }}">回访</button>
<div class="modal fade" id="taskFollowUp{{ $id }}" tabindex="-1" role="dialog" aria-labelledby="taskFollowUp"
     aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true" style="font-size: 36px;">
                    &times;
                </button>
                <h4 class="modal-title" id="myModalLabel">回访</h4>
            </div>
            <div class="modal-body">
                <div class="mb-3">
                    <label for="exampleFormControlInput1" class="form-label">手机号</label>
                    <input type="text" disabled class="form-control" value="{{ $mobile }}">
                </div>
                <div class="mb-3">
                    <label for="exampleFormControlInput1" class="form-label">微信号</label>
                    <input type="text" disabled class="form-control" value="{{ $wechat }}">
                </div>
                @if(!is_null($remark))
                    <div style="white-space:nowrap; margin-top:2%">
                        <div class="panel panel-primary">
                            <div class="panel-heading">原始备注</div>
                            <div class="row">
                                <div class="panel-body"
                                     style="width:96%;margin-left:15px;overflow:auto;white-space:normal;">
                                    {{ $remark }}
                                </div>
                            </div>
                        </div>
                    </div>
                @endif
                <div class="mb-3">
                    <label for="exampleFormControlInput1" class="form-label">状态</label>
                    <select type="text" name="status{{ $id }}" class="form-control">
                        @foreach(__('task.followStatusArr') as $key => $value)
                            <option value="{{ $key }}">{{ $value }}</option>
                        @endforeach
                    </select>
                </div>
                <div class="mb-3">
                    <label for="exampleFormControlInput1" class="form-label">回访备注</label>
                    <textarea name="remark{{ $id }}" class="form-control" id="" cols="30" rows="10"></textarea>
                </div>
                @if(!empty(json_decode($extends, true)))
                    <div style="overflow-x:auto;white-space:nowrap;">
                        <table class="table table-hover grid-table">
                            <thead style="text-align:center">
                            <tr>
                                <th>回访记录</th>
                            </tr>
                            <tr>
                                <th>状态</th>
                                <th>备注</th>
                                <th>时间</th>
                            </tr>
                            </thead>
                            <tbody>
                            @foreach(json_decode($extends, true) as $value)
                                <tr>
                                    <td>{{ $value['status'] }}</td>
                                    <td>{{ $value['remark'] }}</td>
                                    <td>{{ $value['time'] }}</td>
                                </tr>
                            @endforeach
                            </tbody>
                        </table>
                    </div>
                @endif
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <button type="button" class="btn btn-primary" onclick="taskFollowUp({{ $id }})">提交</button>
            </div>
        </div>
    </div>
</div>
<script>
    function taskFollowUp(id) {
        ajaxPostFunc('/admin/ajax/taskFollowUp', {
            id: id,
            status: $("select[name='status" + id + "'] option:selected").val(),
            remark: $("textarea[name='remark" + id + "']").val(),
            _token: $.admin.token
        }, {}, res => {
            console.log(res);
            window.location.reload();
        });
    }
</script>
